package com.hznu.stmanage.serviceImpl;

import com.hznu.stmanage.dao.ManagerMapper;
import com.hznu.stmanage.entity.Manager;
import com.hznu.stmanage.service.BaseService;
import com.hznu.stmanage.service.ManagerService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by J_Vino on 16/3/6.
 */
@Transactional(rollbackFor = Exception.class)
@Service
public class ManagerServiceImpl extends BaseService implements ManagerService {

    ManagerMapper managerMapper = null;
    public void setMapper()
    {
        if(managerMapper==null)
            managerMapper = getManagerMapper();//1.获取相关mapper
    }
    public int deleteByPrimaryKey(Long id) {
        setMapper();
        return managerMapper.deleteByPrimaryKey(id);
    }

    public int insert(Manager record) {
        setMapper();
        return managerMapper.insert(record);
    }

    public int insertSelective(Manager record) {
        setMapper();
        return managerMapper.insertSelective(record);
    }

    public Manager selectByPrimaryKey(Long id) {
        setMapper();
        return managerMapper.selectByPrimaryKey(id);
    }

    public int updateByPrimaryKeySelective(Manager record) {
        setMapper();
        return managerMapper.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(Manager record) {
        setMapper();
        return managerMapper.updateByPrimaryKey(record);
    }

    public Manager findByUsername(String username) {
        setMapper();
        return managerMapper.selectByUsername(username);
    }
}
